<template>
  <div>
    <audio id="welcomeAudio" controls="controls" hidden :src="url" ref="refaudio"></audio>
  </div>
</template>

<script setup>
import { defineExpose,ref, onMounted, nextTick } from 'vue'

const props = defineProps({
  audiourl: String
})

const refaudio = ref(null)
const url = ref(props.audiourl)

const play = () => {
  url.value = props.audiourl
  console.log("打印当前音频地址：" + props.audiourl)
  refaudio.value.currentTime = 0
  refaudio.value.load()
  nextTick(() => {
    refaudio.value.play()
  })
}

defineExpose({
  play: play
})
</script>

<style scoped>
/* 独立组件的样式，写这里，支持标准的css语法 */
</style>